<template>
  <div>
    <el-button
      type="primary"
      class="crebut"
      icon="el-icon-plus"
      @click="TianJiaLuY"
      >添加</el-button
    >
    <el-dialog title="提示" :visible.sync="dialogVisible" width="30%">
      <a-radio-group v-model="value" @change="onChange">
        <a-radio
          v-for="(v, index) in lists"
          :key="index"
          :style="radioStyle"
          :value="v.tid"
        >
          添加 {{ v.tname }}
        </a-radio>
      </a-radio-group>
      <span slot="footer" class="dialog-footer">
        <el-button @click="dialogVisible = false">取 消</el-button>
        <el-button type="primary" @click="TianJiaLuYrouter">确 定</el-button>
      </span>
    </el-dialog>
  </div>
</template>
<script>
import axios from "../../api/home";
export default {
  data() {
    return {
      dialogVisible: false,
      value: 1,
      radioStyle: {
        display: "block",
        height: "30px",
        float: "left",
        lineHeight: "30px",
      },
      lists: [],
    };
  },
  methods: {
    TianJiaLuY() {
      this.dialogVisible = true;
      this.lists = [];
      axios
        .tseleLise()
        .then((res) => {
          this.lists = res.data.list;
        })
        .catch((error) => {
          this.$message.error(error.message);
        });
    },
    // 确定
    TianJiaLuYrouter() {
      if (this.value == 1) {
        this.dialogVisible = false;
        this.$router.push({
          path: "/ItemManagement/danxuan?id=" + this.value,
          params: {
            id: 1,
          },
        });
      } else if (this.value == 2) {
        this.dialogVisible = false;
        this.$router.push({
          path: "/ItemManagement/fillInTheBlanks?id=" + this.value,
          params: {
            id: 2,
          },
        });
      } else if (this.value == 5) {
        this.dialogVisible = false;
        this.$router.push({
          path: "/ItemManagement/Multiplechoice?id=" + this.value,
          params: {
            id: 3,
          },
        });
      } else if (this.value == 6) {
        this.dialogVisible = false;
        this.$router.push({
          path: "/ItemManagement/judge?id=" + this.value,
          params: {
            id: 4,
          },
        });
      }else if (this.value == 7) {
        this.dialogVisible = false;
        this.$router.push({
          path: "/ItemManagement/jianda?id=" + this.value,
          params: {
            id: 5,
          },
        });
      }
    },
    onChange(e) {
      console.log("radio checked", e.target.value);
    },
  },
};
</script>
<style scoped>
.crebut {
  float: left;
  margin-right: 20px;
  margin-bottom: 30px;
  margin-top: 20px;
}
.content {
  width: 50%;
}
.but {
  position: relative;
  top: -63px;
}
</style>
